package com.wzk.dwetl

import org.apache.spark.sql.SparkSession

object Cube {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder()
      .enableHiveSupport()
      .appName(this.getClass.getName)
      .master("local[*]")
      .getOrCreate()
    val user = spark.read.table("dws.tfc_app_agr_user")
    val global = spark.read.table("dwd.user_guid_global")
    user.createTempView("user")
    global.createTempView("global")

    spark.sql(
      """
        |
        |select
        | t.province,
        | t.city,
        | t.region,
        | t.hour_range,
        | t.device_type,
        | t.os_name,
        | t.start_page,
        | t.end_page,
        | t.isnew,
        | t.pv_cnt,
        | t.session_cnt,
        | t.time_long,
        | t.return_user_rnt,
        | t.jumpout_cnt,
        | t.jumpout_user_cnt,
        | g.id
        |from user t
        |join global g
        |on t.guid = g.guid
        |
        |""".stripMargin).show()
  }
}
